package validator

import "regexp"

type phoneType struct {
}

var phoneReg = regexp.MustCompile("^1[3-9][0-9]{9}$")

func (p *phoneType) Validate(name string, val string, required bool) (bool, string) {
	if val == "" {
		if required {
			return false, name + "不能为空"
		}
		return true, ""
	}

	if !phoneReg.MatchString(val) {
		return false, name + "应为11位手机号"
	}

	return true, ""
}
